package org.aeon.colorfulplanebattle.view.listener;

import org.aeon.colorfulplanebattle.constant.DirectionE;
import org.aeon.colorfulplanebattle.flying.entity.Plane;

import static org.aeon.colorfulplanebattle.constant.DirectionE.*;

/**
 * @author: MissingAeon
 * @date: 2024/1/11 14:50
 * @description:
 */
public enum SustainMoveE implements Action {
    // 正方向
    SUSTAIN_UP(UP),
    SUSTAIN_DOWN(DOWN),
    SUSTAIN_LEFT(LEFT),
    SUSTAIN_RIGHT(RIGHT);

    private static Plane myPlane;
    private final DirectionE direction;
    private boolean flag;

    SustainMoveE(DirectionE direction) {
        this.direction = direction;
    }

    public static void setMyPlane(Plane myPlane) {
        SustainMoveE.myPlane = myPlane;
    }

    @Override
    public void run() {
        if (flag) {
            myPlane.move(direction);
        }
    }

    @Override
    public boolean isFlag() {
        return flag;
    }

    @Override
    public void setFlag(boolean flag) {
        this.flag = flag;
    }
}
